Skip to content

fix: restore live-decode regressions guards#15

Open
abdulsaheel wants to merge 2 commits into
mainfrom
fix/restore-live-decode-guards
Open

fix: restore live-decode regressions guards#15
abdulsaheel wants to merge 2 commits into
mainfrom
fix/restore-live-decode-guards

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reverts three uncommitted, unproven tweaks to known-good behavior, each now documented in place:
    • parseRealtimeHr's RR sanity clamp restored to 200-2500ms (24-300bpm) — a relaxation to v>0 let corrupted/out-of-range timing values straight into live RR with no guard.
    • _r10Motion's detrend window restored to 9 — a widen to 25 had no test coverage and risked attenuating genuine step periodicity (the autocorrelation lag range it feeds is 7-40 samples).
    • wristOn restored to hr>0skinContact>50 broke the 2934-case parity suite (28 misses, all false-negative "not worn"); skinContact is contact quality, not wear, exactly as already documented, and the fixture proves it (28 real v24 records with hr=87-97 clearly worn, skinContact<=50).
  • Removes ts/ (the TypeScript reference implementation) — superseded by the frozen decode_parity_cases.json oracle, which dart test already runs against with no runtime dependency on ts/.

Test plan

  • dart test — 71/71 passing, including the full 2934-case parity suite.

(Re-opened as a fresh branch/PR — the prior PR #14 covering this same work was closed without merging.)

Summary by CodeRabbit

  • Refactor

    • Removed the legacy TypeScript live-data and record-decoding interfaces.
    • Retained validated heart-rate interval handling and existing motion-processing behavior.
  • Chores

    • Removed an obsolete decoder verification script.
    • Added clarification around heart-rate timing validation and motion/contact interpretation.

Three uncommitted tweaks had crept in without justification or test
coverage; reverted all three back to known-good behavior and left a
comment at each site so they don't get silently re-applied:

- wristOn: skinContact>50 broke the parity suite (2906/2934, all 28
  misses on wrist_on) — 28 real v24 records show hr=87-97 (clearly
  worn) with skinContact<=50, proving skinContact is contact quality,
  not wear, exactly as already documented. Back to hr>0, which matches
  the oracle on every case.
- parseRealtimeHr's RR sanity clamp (200-2500ms = 24-300bpm) had been
  relaxed to `v>0`, letting corrupted/out-of-range timing values
  straight into live RR with no guard.
- _r10Motion's detrend window had been widened 9->25 with nothing
  backing it; ±25 approaches the 7-40 sample autocorrelation lag range
  it feeds, risking attenuation of genuine step periodicity. No test
  (parity or otherwise) exercises steps_inc/activity from R10, so
  there was no way to validate the change either way.

dart test: 71/71 passing, including the full 2934-case parity suite.
Was the original reference the Dart decoders were ported from and kept
in parity with (7 commits, right up through the latest feature work),
not a one-off leftover — but decode_parity_cases.json is now the
frozen, self-contained oracle dart test actually runs against, with no
runtime dependency on ts/ (verified: no test/config spawns node/tsc
against it). Drops the unported v25-handling WIP that was sitting in
ts/live.ts uncommitted; that work is not carried over to live.dart.
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 31232b2b-fedc-4035-a2e2-3dc284badcd3

📥 Commits

Reviewing files that changed from the base of the PR and between 02fc8e5 and be1d530.

📒 Files selected for processing (5)
  • lib/src/control.dart
  • lib/src/live.dart
  • ts/live.ts
  • ts/records.ts
  • ts/test_decoder.ts
💤 Files with no reviewable changes (3)
  • ts/records.ts
  • ts/live.ts
  • ts/test_decoder.ts

📝 Walkthrough

Walkthrough

The change documents retained realtime RR validation and live motion/contact-decoding behavior in Dart. It also removes the TypeScript live decoder, Type-24 record parser, and associated decoder test script.

Changes

Decoder cleanup

Layer / File(s) Summary
Realtime RR validation notes
lib/src/control.dart
Comments explain why both RR slots retain the 200–2500 ms validation range.
Live decoder notes and TypeScript removal
lib/src/live.dart, ts/live.ts, ts/records.ts, ts/test_decoder.ts
Comments document motion-window and contact-decoding behavior; legacy TypeScript decoders and their test script are deleted.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: localhoop

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the PR’s main intent: restoring live-decode behavior by reverting regressions and related guards.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/restore-live-decode-guards

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant